import { Robot, Rect, Group, Leafer } from "leafer-game";
const playerWalkSprites = [0, 1, 2, 3, 4, 5]
const playerAttackSprites = [36, 37, 38, 39]
export class Enemy {
    enemy: Robot;
    collider: Rect;
    group: Group;
    leafer: Leafer;
    constructor(){
        this.leafer = new Leafer();
        this.group = new Group({
            width: 32,
            height: 32,
            x: 100,
            y: 100,
        });
        this.collider = new Rect({
            width: 18,
            height: 24,
            stroke: 'red',
            offsetX: 7,
            offsetY: 3,
        })
        this.enemy = new Robot({
            robot: { url: '/Enemies/Skeleton.png', size: { width: 32, height: 32 }, total: 60 },
            actions: {  // 预设游戏动作（通过动作帧）
                idleArrowDown: playerWalkSprites,
                idleArrowRight: playerWalkSprites.map((i) => i + 6),
                idleArrowLeft: playerWalkSprites.map((i) => i + 6),
                idleArrowUp: playerWalkSprites.map((i) => i + 12),
                walkArrowDown: playerWalkSprites.map((i) => i + 18),
                walkArrowRight: playerWalkSprites.map((i) => i + 24),
                walkArrowLeft: playerWalkSprites.map((i) => i + 24),
                walkArrowUp: playerWalkSprites.map((i) => i + 30),
                attackArrowDown: playerAttackSprites,
                attackArrowRight: playerAttackSprites.map((i) => i + 6),
                attackArrowLeft: playerAttackSprites.map((i) => i + 6),
                attackArrowUp: playerAttackSprites.map((i) => i + 12),
                die: playerAttackSprites.map((i) => i + 18),
            },
            action: 'idleArrowDown' // 设置默认动作
        });
        this.group.add([this.collider, this.enemy])
        // this.leafer.add(this.group)
    }
}
